import { Router } from 'vue-router'
import { complInfo, hotelInfo,adminInfo, addAdmin, mainInfo, userInfo, addKinds } from '@/view/admin'
import  updatePassword  from '../view/updatePassword.vue'

export const admin = [
    { title:'人员管理', icon: 'User', meta: 'main/user', list:[] },
    { title:'酒店管理', icon: 'Menu', meta: 'main/hotel', list:[] },
    { title:'售后管理', icon: 'Edit', meta: 'main/postSale', list:[] }
]
const adminRouter = [
    {
        path:'/main/user/mainInfo',
        name:'mainInfo',
        component: mainInfo
    },
    {
        path:'/main/user/userInfo',
        name:'userInfo',
        component: userInfo
    },
    {
        path:'/main/user/adminInfo',
        name:'adminInfo',
        component: adminInfo
    },
    {
        path:'/main/user/addAdmin',
        name:'addAdmin',
        component: addAdmin
    },
    {
        path:'/main/hotel/hotelInfo',
        name:'hotelInfo',
        component: hotelInfo
    },
    {
        path:'/main/hotel/addKinds',
        name:'addKinds',
        component: addKinds
    },
    {
        path:'/main/postSale/complInfo',
        name:'complInfo',
        component: complInfo
    },
    {
        path:'/main/updatePassword',
        name:'updatePassword',
        component: updatePassword,
    }
]

export function addAdminRoute(router:Router) {
    adminRouter.forEach(el => {
        router.addRoute('main', { path: el.path, name: el.name, component: el.component })
    })
    router.getRoutes().forEach(el => {
        if (el.name === 'main') {
            el.redirect = '/main/user/mainInfo'
        }
    })
}